package com.miracle9.game.service;

import com.miracle9.game.dao.IncomeRankDao;
import com.miracle9.game.dao.SystemConfigServiceDao;
import com.miracle9.game.dao.UserServiceDao;
import com.miracle9.game.entity.IncomeRank;
import com.miracle9.game.entity.SystemConfig;
import com.miracle9.game.entity.User;
import org.apache.mina.core.session.IoSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("shareService")
public class ShareService {

    @Autowired
    private IncomeRankDao incomeRankDao;
    @Autowired
    private UserServiceDao userServiceDao;
    @Autowired
    private SystemConfigServiceDao systemConfigServiceDao;

    public Map<String, Object> myShare(int userId, IoSession session) {
        User user = (User) userServiceDao.getById(userId);
        SystemConfig systemConfig = systemConfigServiceDao.getSystemConfig();
        Map<String, Object> result = new HashMap<>();
        result.put("gameId", user.getId());
        result.put("promoterId", user.getPromoterName());
        result.put("shareAddress", systemConfig != null ? systemConfig.getShareAddress() : "");
        result.put("teamMemberPeopleNumber", "0");
        result.put("teamMemberActivePeopleNumber", "0");
        result.put("teamMemberAddPeopleNumber", "0");
        result.put("directlyUnderUserPeopleNumber", "0");
        result.put("directlyUnderUserActivePeopleNumber", "0");
        result.put("directlyUnderUserAddPeopleNumber", "0");
        result.put("directlyUnderAgentPeopleNumber", "0");
        result.put("directlyUnderAgentActivePeopleNumber", "0");
        result.put("directlyUnderAgentAddPeopleNumber", "0");
        result.put("yesterdayIncome", "0");
        result.put("todayIncome", "0");
        result.put("gotIncome", "0");
        result.put("canIncome", "0");
        return result;
    }

    public void getIncomeLog(int userId, IoSession session) {
    }

    public void incomeDetail(int userId, IoSession session) {

    }

    public void promotionTutorial(IoSession session) {

    }

    public void queryDirectlyUnderUser(int userId, IoSession session) {

    }

    public Map<String, Object> getIncomeRank(IoSession session) {
        Map<String, Object> result = new HashMap<>();
        List<IncomeRank> list = incomeRankDao.q_CreateSqlList("from IncomeRank order by income desc", new Object[0]);
        for (int i = 0; i < list.size(); i++) {
            result.put(String.valueOf(i), list.get(i));
        }
        return result;
    }

}
